SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_PlazasAfectadasSolicitud
AS
SELECT C.idCola, P.Cupof, 
    CASE P.regimensalarial WHEN 12 THEN NULL 
    ELSE SUM(C.CantidadHoras) END Horas
FROM tb_ColaDeMovimientos C INNER JOIN
    tb_PlazasDeMovimiento PM ON 
    C.idCola = PM.idCola INNER JOIN
    tb_Plazas P ON P.idPlaza = PM.idPlaza
GROUP BY C.idCola, P.cupof, P.regimensalarial
GO
GRANT SELECT ON  [dbo].[vw_PlazasAfectadasSolicitud] TO [SoloVer]
GO
